package com.aioz.security.controller;


import com.aioz.security.aop.annotation.LogInfoAnnotation;
import com.aioz.security.common.ResponseResult;
import com.aioz.security.service.impl.LogServiceImpl;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Aioz
 * @since 2022-11-18
 */
@RestController
@RequestMapping("/log")
public class LogController {

    @Resource
    private LogServiceImpl logService;

    //日志查看
    @PostMapping("/get/all/{currentPage}/{size}")
    @LogInfoAnnotation
    public ResponseResult getLogsPage(@PathVariable Integer currentPage,
                                      @PathVariable Integer size){
        return logService.getLogsPage(currentPage,size);
    }

    //通过用户ID查看
    @PostMapping("/get/userId/{userId}")
    @LogInfoAnnotation
    public ResponseResult getLogsByUserId(@PathVariable Integer userId){
        return logService.getLogsByUserId(userId);
    }

    //通过状态码查看
    @PostMapping("/get/statusCode/{statusCode}")
    @LogInfoAnnotation
    public ResponseResult getLogsByStatusCode(@PathVariable Integer statusCode){
        return logService.getLogsByStatusCode(statusCode);
    }

    //删除日志
    @PostMapping("/delete/{id}")
    public ResponseResult deleteLog(@PathVariable Integer id){
        return logService.deleteLog(id);
    }
}
